<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Redis;

class SettingController extends Controller
{
    //设置图片初始血量
    public function blood(Request $request){
        if($request->has('blood')){
            $pictureBloode = $request->get('blood');
            Redis::set('pictureBloode',$pictureBloode);
            return json_encode(['code'=>200,'msg'=>'设置成功']);
        }else{
            $bloode =  Redis::get('pictureBloode');
            return json_encode(['code'=>200,'blood'=>$bloode]);
        }

    }
    //设置用户初始可用票数
    public function ticket(Request $request){
        if($request->has('ticket')){
            $userTicket = $request->get('ticket');
            Redis::set('userTicket',$userTicket);
            return json_encode(['code'=>200,'msg'=>'设置成功']);
        }else{
            $ticket =  Redis::get('userTicket');
            return json_encode(['code'=>200,'ticket'=>$ticket]);
        }

    }
    //设置图片最高血量
    public function maxBlood(Request $request){
        if($request->has('maxBlood')){
            $maxBlood = $request->get('maxBlood');
            Redis::set('maxBlood',$maxBlood);
            return json_encode(['code'=>200,'msg'=>'设置成功']);
        }else{
            $maxBlood =  Redis::get('maxBlood');
            return json_encode(['code'=>200,'maxBlood'=>$maxBlood]);
        }

    }
    //分享图片增加血量
    public function addPictureBlood(Request $request){
        if($request->has('addPictureBlood')){
            $addPictureBlood = $request->get('addPictureBlood');
            Redis::set('addPictureBlood',$addPictureBlood);
            return json_encode(['code'=>200,'msg'=>'设置成功']);
        }else{
            $addPictureBlood =  Redis::get('addPictureBlood');
            return json_encode(['code'=>200,'addPictureBlood'=>$addPictureBlood]);
        }

    }
    //分享图片增加血量
    public function addUserTicket(Request $request){
        if($request->has('addUserTicket')){
            $addUserTicket = $request->get('addUserTicket');
            Redis::set('addUserTicket',$addUserTicket);
            return json_encode(['code'=>200,'msg'=>'设置成功']);
        }else{
            $addUserTicket =  Redis::get('addUserTicket');
            return json_encode(['code'=>200,'addUserTicket'=>$addUserTicket]);
        }

    }
    //屏蔽用户最近几天内的历史记录
    public function banHistoryTime(Request $request){
        if($request->has('banHistoryTime')){
            $banHistoryTime = $request->get('banHistoryTime');
            Redis::set('banHistoryTime',$banHistoryTime);
            return json_encode(['code'=>200,'msg'=>'设置成功']);
        }else{
            $banHistoryTime =  Redis::get('banHistoryTime');
            return json_encode(['code'=>200,'banHistoryTime'=>$banHistoryTime]);
        }

    }

}
